home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_14.lha
/
6_14
/
6_14c.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
904b
|
40 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ class string from section 6.9
/ rewritten to use member definitions
lass string
struct srep
{
char *s; // pointer to data
int n; // reference count
};
srep *p;
ublic:
string(char *); // string x = "abc"
string(); // string x;
string(string &); // string x = string ...
string& operator=(char *);
string& operator=(string &);
~string();
char& operator[](int i);
friend ostream& operator<<(ostream&, string&);
friend istream& operator>>(istream&, string&);
int operator==(char *s)
{ return strcmp(p->s, s) == 0; }
int operator==(string &y)
{ return strcmp(p->s, y.p->s) == 0; }
int operator!=(char *s)
{ return strcmp(p->s, s) != 0; }
int operator!=(string &y)
{ return strcmp(p->s, y.p->s) != 0; }
;